<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" import="java.util.*"%>
<html  class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/xadmin.css">
     <style>
	body {
		background-color: #ddeef2 !important;
		 }
	</style>
</head>
<body class="login-bg">
<% if ("0".equals(request.getParameter("message"))) { %>
    <script>alert("密码更新成功！");</script>
<% } %>
<%String username=request.getParameter("username"); %>
<div class="login layui-anim layui-anim-up">
    <div class="message">新闻管理系统-修改密码</div>
    <div id="darkbannerwrap"></div>

   <form method="post" action="UpdUserServlet" class="layui-form" onsubmit="return validate()" accept-charset="UTF-8">
    <input name="username" id="username" placeholder="用户名" type="text" class="layui-input" readonly value=<%=username %>>
    <hr class="hr15">
    <input name="oldpassword" id="oldpassword" placeholder="旧密码" type="password" class="layui-input" required>
    <hr class="hr15">
    <input name="password" id="password" placeholder="新密码" type="password" class="layui-input" required>
    <hr class="hr15">
    <input name="password1" id="password1" placeholder="确认密码" type="password" class="layui-input" required>
    <p id="tishi"></p>
    <hr class="hr20">
    <input value="修改" id="button" style="width:100%;" type="submit" onclick="comparePasswords()">
    <hr class="hr40" >

<script>
    function comparePasswords() {
        var oldPassword = document.getElementById("oldpassword").value;
        var password = document.getElementById("password").value;
        var tishi = document.getElementById("tishi");

        if (oldPassword === password) {
            tishi.innerHTML = "新密码不能与旧密码相同，请重新输入！";
            tishi.style.color = "red";
            return false;
        }

        if (password !== document.getElementById("password1").value) {
            tishi.innerHTML = "两次输入的密码不一致，请重新输入！";
            tishi.style.color = "red";
            return false;
        } else {
            tishi.innerHTML = "两次输入的密码一致，可以提交！";
            tishi.style.color = "green";
            return true;
        }
    }
</script>
</form>
</div>
</body>
</html>
